package com.creawor.km.util;

import org.apache.log4j.Logger;

import java.util.Date;

public class Memory {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(Memory.class);

	public static void printMemoryInfo(){
		

		System.gc();
    Runtime rt = Runtime.getRuntime();
    float totalMemory = (float) rt.totalMemory() / 1048576.0F;
    float freeMemory = (float) rt.freeMemory() / 1048576.0F;
    float usedMemory = totalMemory - freeMemory;
    float percentUsed = usedMemory / totalMemory * 100.0F;
    
    /*System.out.print("Memory Stats,");
    System.out.print(new Date());
    System.out.print(",");
    System.out.print("totalMemory="+totalMemory);
    System.out.print(",");
    System.out.print("usedMemory="+usedMemory);
    System.out.print(",");
    System.out.println(percentUsed);*/
    
    logger.debug("@@@@@@@@@@@@totalMemory="+totalMemory+"    usedMemory="+usedMemory+"   percentUsed="+percentUsed);
		if (logger.isDebugEnabled()) {
			//logger.debug("@@@@@@@@@@@@totalMemory="+totalMemory+"    usedMemory="+usedMemory+"   percentUsed="+percentUsed);
		}
	}
}
